package gpslmall

import (
	"errors"
	"github.com/astaxie/beego"
)

type OrderRefundReq struct {
	MerchantOrderNo	string	  `json:"merchantOrderNo"` //订单号
}

type OrderRefundRsp struct {
	*BaseRsp
	Content	string	`json:"content"`   //订单号orderId
}

func Refund(shopKey,secrecode,orderId string)(err error){
	method := "buyer.orderRefund"
	req := new(OrderRefundReq)
	req.MerchantOrderNo = orderId
	reqURL := "http://106.75.191.107/m.api"
	//reqURL := "http://openapi.oceanz.cn/m.api"
	sdk := NewSDK(reqURL, shopKey, secrecode)
	rsp := new(RequestPayRsp)
	_, err = sdk.Request(method, req, rsp)
	if err != nil {
		beego.Debug("Gpslmall Refund err:", err.Error())
		return
	}
	if rsp.ReturnCode != "00000000" {
	   err = errors.New(rsp.ErrorMsg)
	}
	return
}
